#include"RingQueue.hpp"
void* ProdRunFunc(void* args)
{
    RingQueue<DataType>* loopQueue = static_cast<RingQueue<DataType>*>(args);
    while(true)
    {
        //生产数据
        DataType data = rand() % 10 + 1;
        loopQueue->Push(data);
        std::cout<<"生产者生产数据-> "<<data<<std::endl;
    }
}
void* ConRunFunc(void* args)
{
    RingQueue<DataType>* loopQueue = static_cast<RingQueue<DataType>*>(args);
    while(true)
    {
         sleep(1);  
        //消费数据
        DataType data = 0;
        loopQueue->Pop(&data);
        std::cout<<"消费者消费的数据-> "<<data<<std::endl;
    }
}
int main()
{
    srand(time(nullptr) ^ 1314);
    RingQueue<DataType>* loopQueue = new RingQueue<DataType>();
    pthread_t Productor,Consumer;
    pthread_create(&Productor,nullptr,ProdRunFunc,loopQueue);
    pthread_create(&Consumer,nullptr,ConRunFunc,loopQueue);
    pthread_join(Productor,nullptr);
    pthread_join(Consumer,nullptr);

    return 0;
}